package com.custom.jdbc.executor.convert;

import com.custom.comm.utils.CustomUtil;
import com.custom.jdbc.handler.TypeHandler;

import java.beans.PropertyDescriptor;

/**
 * @author XiaoBai
 * @since 2024/3/30 0030 21:32
 */
public class PropertyCache {

    private final String fieldName;
    private final boolean baseType;
    private final PropertyDescriptor descriptor;
    private final TypeHandler<?> typeHandler;

    public PropertyCache(PropertyDescriptor descriptor) {
        this.descriptor = descriptor;
        this.fieldName = descriptor.getName();
        Class<?> fieldType = descriptor.getPropertyType();
        this.baseType = CustomUtil.isBasicClass(fieldType);
        this.typeHandler = AbstractRsHandler.getTargetTypeHandler(fieldType);
    }


    public String getFieldName() {
        return fieldName;
    }

    public boolean isBaseType() {
        return baseType;
    }

    public PropertyDescriptor getDescriptor() {
        return descriptor;
    }

    public TypeHandler<?> getTypeHandler() {
        return typeHandler;
    }

}
